package com.google.gwt.sample.stockwatcher.client;

public class PanelUtils {
  
  /** Some random body text for testing in various panels. */
  
  public static String randomText() {
    String text =
      "Blah, blah, blah, blah, blah, blah, blah. " +
      "Yadda, yadda, yadda, yadda, yadda, yadda. ";
    for(int i=0; i<5; i++) {
      text = text + text;
    }
    return("<span class='bodyText'>" +
           text + "</span>");
  }
  
  /** Given a string like "foo13", returns 13 as an int.
   *  Returns 0 if there are problems parsing the string.
   */
  public static int findIndex(String label) {
    int index = 0;
    try {
      label = label.replaceAll("[^0-9]+", "");
      index = Integer.parseInt(label);
    } catch(Exception e) {}
    return(index);
  }
}
